Hệ thống quản lý ISP trong PHP

1 <?php
2     
// Start from getting the hader which contains some settings we need
3     require_once
'includes/header.php';
4
5     
// Redirect visitor to the login page if he is trying to access
6     
// this page without being logged in
7     
if (!isset($_SESSION['admin_session']) )
8     {
9         $commons->redirectTo(SITE_PATH.
'login.php');
10     }
11 ?>
12         <?php
13             require_once
"includes/classes/admin-class.php";
14             $admins =
new Admins($dbh);
15         ?>
16
17     <div
class="dashboard">
18
19     <div
class="col-md-12 col-sm-12" id="employee_table">
20         <div
class="panel panel-default">
21             <div
class="panel-heading">
22             <h4>Employeer</h4>
23             </div>
24             <div
class="panel-body">
25                 <div
class="col-md-6">
26                 <button type=
"button" name="add" id="add" class="btn btn-info" data-toggle="modal" data-target="#add_data_Modal">ADD</button>
27                 </div>
28                 <div
class="col-md-6">
29                     <form
class="form-inline pull-right">
30                       <div
class="form-group">
31                         <label
class="sr-only" for="search">Search for</label>
32                         <div
class="input-group">
33                           <div
class="input-group-addon"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></div>
34                           <input type=
"text" class="form-control" id="search" placeholder="Type a name">
35                           <div
class="input-group-addon"></div>
36                         </div>
37                       </div>
38                       <!-- <button type=
"submit" class="btn btn-info">Search</button> -->
39                     </form>
40                 </div>
41                 <?php
if ( isset($_SESSION['errors']) ) {?>
42                 <div
class="pannel panel-warning">
43                     <?php
foreach ($_SESSION['errors'] as $error):?>
44                         <li><?= $error ?></li>
45                     <?php endforeach ?>
46                 </div>
47                 <?php session::destroy(
'errors');
48                 } ?>
49             </div>
50         <table
class="table table-striped" id="grid-basic">
51             <thead
class="thead-inverse">
52               <tr
class="info">
53                 <th>ID </th>
54                 <th>Action</th>
55                 <th>Username</th>
56                 <th>Name</th>
57                 <th>Email</th>
58                 <th>Cellphone</th>
59                 <th>Address</th>
60               </tr>
61             </thead>
62           <tbody>
63           </tbody>
64         </table>
65     </div>
66     </div>
67     <!-- invisible content -->
68     <!-- Insert modal
for users -->
69     <div id=
"add_data_Modal" class="modal fade">
70         <div
class="modal-dialog">
71             <div
class="modal-content">
72                 <div
class="modal-header">
73                     <button type=
"button" class="close" data-dismiss="modal">&times;</button>
74                     <h4>Insert Data</h4>
75                 </div>
76                     <form action=
"" method="POST" id="insert_form">
77                 <div
class="modal-body">
78                         <!-- form content -->
79                           <div
class="form-group">
80                             <label
for="username">Username</label>
81                             <input type=
"username" class="form-control" id="username" name="username" aria-describedby="emailHelp" placeholder="Username" required>
82                           </div>
83                           <div
class="form-group">
84                             <label
for="password">Password</label>
85                             <input type=
"password" class="form-control" id="password" name="password" placeholder="Password" required>
86                           </div>
87                           <div
class="form-group">
88                             <label
for="repassword">Re enter Password</label>
89                             <input type=
"password" class="form-control" id="repassword" name="repassword" placeholder="Re enter password" required>
90                           </div>
91                           <div
class="form-group">
92                             <label
for="email">Email</label>
93                             <input type=
"text" class="form-control" id="email" name="email" placeholder="Email Address" required>
94                           </div>
95                           <div
class="form-group">
96                             <label
for="fullname">Full Name</label>
97                             <input type=
"text" class="form-control" id="fullname" name="fullname" placeholder="Full Name" required>
98                           </div>
99
100                           <div
class="form-group">
101                             <label
for="address">Address</label>
102                             <input type=
"textarea" class="form-control" id="address" name="address" placeholder="Address">
103                           </div>
104
105                           <div
class="form-group">
106                             <label
for="contact">Contact</label>
107                             <input type=
"tel" class="form-control" id="contact" name="contact" placeholder="Contact">
108                           </div>
109                 </div>
110                 <div
class="modal-footer">
111                             <button type=
"submit" class="btn btn-primary">Submit</button>
112                     <a href=
"#" class="btn btn-warning" data-dismiss="modal">Cancel</a>
113                 </div>
114                     </form>
115             </div>
116         </div>
117     </div>
118
119     <?php
120     include
'includes/footer.php';
121     ?>
122     <script type=
"text/javascript">
123     $(
'#insert_form').on('submit',function(event){
124         
event.preventDefault();
125         $.ajax({
126             url:
"user_approve.php?p=add",
127             method:
"POST",
128             data:$(
'#insert_form').serialize(),
129             success: function (data) {
130                 $(
'#insert_form')[0].reset();
131                 $(
'#add_data_Modal').modal('hide');
132                 viewData();
133             }
134         });
135     });
136     function viewData() {
137         $.ajax({
138             method:
"GET",
139             url:
"user_approve.php",
140             success: function(data){
141                 $(
'tbody').html(data);
142             }
143         });
144     }
145     function delData(del_id){
146         
var id = del_id;
147         $.ajax({
148             method:
"POST",
149             url:
"user_approve.php?p=delta",
150             data:
"id="+id,
151             success: function (data){
152                 viewData();
153             }
154         });
155     }
156     function updateData(str){
157         
var user_id = str;
158         
var username = $('#usr-'+str).val();
159         
var full_name = $('#fnm-'+str).val();
160         
var email = $('#em-'+str).val();
161         
var contact = $('#con-'+str).val();
162         
var address = $('#ad-'+str).val();
163         $.ajax({
164             method:
"POST",
165             url:
"user_approve.php?p=edit",
166             data:
"username="+username+"&full_name="+full_name+"&email="+email+"&contact="+contact+"&address="+address+"&user_id="+user_id,
167             
//console.log(data);
168             success: function (data){
169                 viewData();
170             }
171         });
172     }
173     window.onload = viewData();
174     </script>
175     <script type=
"text/javascript">
176       $(function() {
177         grid = $(
'#grid-basic');
178
179         
// handle search fields of members key up event
180         $(
'#search').keyup(function(e) {
181           text = $(
this).val(); // grab search term
182
183           
if(text.length > 1) {
184             grid.find(
'tr:has(td)').hide(); // hide data rows, leave header row showing
185
186             
// iterate through all grid rows
187             grid.find(
'tr').each(function(i) {
188               
// check to see if search term matches Name column
189               
if($(this).find('.search').text().toUpperCase().match(text.toUpperCase()))
190                 $(
this).show(); // show matching row
191             });
192           }
193           
else
194             grid.find(
'tr').show(); // if no matching name is found, show all rows
195         });
196         
197       });
198     </script>


Gõ tìm kiếm nhanh...